using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class ProductVariantAttributeValueMap : EntityTypeConfiguration<ProductVariantAttributeValue>
    {
        public ProductVariantAttributeValueMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Name)
                .IsRequired()
                .HasMaxLength(400);

            this.Property(t => t.ColorSquaresRgb)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("ProductVariantAttributeValue");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.ProductVariantAttributeId).HasColumnName("ProductVariantAttributeId");
            this.Property(t => t.AttributeValueTypeId).HasColumnName("AttributeValueTypeId");
            this.Property(t => t.AssociatedProductId).HasColumnName("AssociatedProductId");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.ColorSquaresRgb).HasColumnName("ColorSquaresRgb");
            this.Property(t => t.PriceAdjustment).HasColumnName("PriceAdjustment");
            this.Property(t => t.WeightAdjustment).HasColumnName("WeightAdjustment");
            this.Property(t => t.Cost).HasColumnName("Cost");
            this.Property(t => t.Quantity).HasColumnName("Quantity");
            this.Property(t => t.IsPreSelected).HasColumnName("IsPreSelected");
            this.Property(t => t.DisplayOrder).HasColumnName("DisplayOrder");
            this.Property(t => t.PictureId).HasColumnName("PictureId");

            // Relationships
            this.HasRequired(t => t.Product_ProductAttribute_Mapping)
                .WithMany(t => t.ProductVariantAttributeValues)
                .HasForeignKey(d => d.ProductVariantAttributeId);

        }
    }
}
